package ca.tatham.triplipse.filter;

import java.util.ArrayList;
import java.util.Collection;

import ca.tatham.triplipse.PrefixProvider;
import ca.tatham.triplipse.RdfStatement;

/**
 * A group of TripleFilters. All included filters must meet the criteria for a
 * Statement to return true to <code>includeStatement(Statement)</code>
 * 
 * @author BenTatham
 */
public class RdfStatementFilterComposite implements IRdfStatementFilter {

	private final Collection<IRdfStatementFilter> m_filters = new ArrayList<IRdfStatementFilter>();

	public RdfStatementFilterComposite() {
		// do nothing
	}

	public Collection<IRdfStatementFilter> getFilters() {
		return m_filters;
	}

	public void addFilter(IRdfStatementFilter filter) {
		if (filter != null) {
			m_filters.add(filter);
		}
	}

	public boolean includeStatement(RdfStatement statement) {
		return includeStatement(statement, null);
	}

	public boolean includeStatement(RdfStatement statement,
			PrefixProvider prefixes) {
		boolean result = true;
		for (IRdfStatementFilter filter : m_filters) {
			result &= filter.includeStatement(statement, prefixes);
		}
		return result;
	}
}
